package com.rc.saas.mini.controller.msg;

import com.rc.saas.base.MinipBaseController;

//@Controller
//@RequestMapping("/customMsg")
//@Api(tags = "13.信息相关（未开始）")
public class CustomMsgController extends MinipBaseController {
    //private static Logger logger = LogManager.getLogger(CustomMsgController.class);
    //
    //@Autowired
    //private MemberInfoService memberInfoService;
    //
    //@Autowired
    //private TenantCustomMsgService tenantCustomMsgService;
    //
    ///**
    // * 获取客服信息列表
    // */
    //@ResponseBody
    //@RequestMapping("/listCustomMsg")
    //@ApiOperation(value = "获取客服信息列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    //@ApiImplicitParams({
    //        @ApiImplicitParam(name = "pageNo", paramType = "query", value = "页量", required = true),
    //        @ApiImplicitParam(name = "pageNo", paramType = "query", value = "页码", required = true),
    //})
    //public TResponse listCustomMsg(HttpServletRequest request,
    //                               @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
    //                               @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
    //    String tenantCode = (String) request.getSession().getAttribute(SessionConstants.SESSION_TENANT);
    //    if (tenantCode == null || StringUtils.isBlank(tenantCode)) {
    //        logger.error("找不到对应运营商信息:{}", tenantCode);
    //        return TResponse.FAIL("找不到对应运营商信息");
    //    }
    //    LoginInfoVo loginInfo = readLoginInfo(request);
    //    if (loginInfo == null) {
    //        return TResponse.FAIL_LOGIN();
    //    }
    //
    //    MemberInfo member = memberInfoService.selectByPrimaryKey(loginInfo.getMemberId());
    //    if (member == null) {
    //        return TResponse.FAIL_LOGIN();
    //    }
    //    logger.info("CustomMsgController.listCustomMsg.tenantCode:{},mobile:{}", tenantCode, member.getMobile());
    //
    //    PageInfo<TenantCustomMsg> tenantCustomMsgPageInfo = tenantCustomMsgService.listPageTenantCustomMsg(tenantCode, member.getMemberId(),pageNo, pageSize);
    //    Collections.reverse(tenantCustomMsgPageInfo.getList());
    //    //更新member表 last_custom_msg_time
    //    MemberInfo memberVo = new MemberInfo();
    //    memberVo.setMemberId(member.getMemberId());
    //    memberVo.setTenantCode(member.getTenantCode());
    //    memberVo.setLastCustomMsgTime(new Date());
    //    memberInfoService.updateByPrimaryKeySelective(memberVo);
    //    //TODO 修改为已读
    //    for (TenantCustomMsg tenantCustomMsg : tenantCustomMsgPageInfo.getList()) {
    //        if ("0".equals(tenantCustomMsg.getIsRead()) && "1".equals(tenantCustomMsg.getMsgType())) {
    //            tenantCustomMsg.setIsRead("1");
    //            tenantCustomMsg.setLastUpdatedTime(new Date());
    //            tenantCustomMsgService.updateByPrimaryKeySelective(tenantCustomMsg);
    //        }
    //    }
    //    Map map = new HashMap();
    //    map.put("tenantCustomMsgPageInfo", tenantCustomMsgPageInfo);
    //    map.put("headImg", member.getHeadImg());
    //    TResponse tResponse = TResponse.SUCCESS();
    //    tResponse.put(map);
    //    return tResponse;
    //}
    //
    ///**
    // * 发送客服信息
    // */
    //@ResponseBody
    //@RequestMapping("/sendCustomMsg")
    //@ApiOperation(value = "发送客服信息", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    //public TResponse sendCustomMsg(HttpServletRequest request, String msg) {
    //    String tenantCode = (String) request.getSession().getAttribute(SessionConstants.SESSION_TENANT);
    //    LoginInfoVo loginInfo = readLoginInfo(request);
    //    if (loginInfo == null) {
    //        return TResponse.FAIL_LOGIN();
    //    }
    //
    //    MemberInfo member = memberInfoService.selectByPrimaryKey(loginInfo.getMemberId());
    //    if (member == null) {
    //        return TResponse.FAIL_LOGIN();
    //    }
    //
    //    try {
    //        tenantCustomMsgService.insertCustomMsg(member.getMemberId(), member.getTenantCode(), msg);
    //        return TResponse.SUCCESS();
    //    } catch (Exception e) {
    //        logger.error("发送失败", e);
    //        return TResponse.FAIL("发送失败！！");
    //    }
    //}
}
